package com.qf.ssm.controller;

import com.qf.ssm.entity.Commodity;
import com.qf.ssm.entity.PropertyGroup;
import com.qf.ssm.service.CommodityService;
import com.qf.ssm.utils.ResponseResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("commodity")
public class CommodityController {
    @Resource
    CommodityService commodityService;

    /**
     * 通过id查询商品的信息
     * @param
     * @retur啊啊啊啊
     * 倒霉  倒霉   倒霉
     *
     *
     *
     * */
    @GetMapping("/selectById")
    private ResponseResult<Commodity>selectById(int id){
        return ResponseResult.success(commodityService.selectByPrimaryKey(id));
    }

    /*
    根据id 来删除商品信息
     */
    @GetMapping("/deleteByPrimaryKey")
    private ResponseResult<Integer>deleteByPrimaryKey(int id){
        return ResponseResult.success(commodityService.deleteByPrimaryKey(id));
    }
    /*
    增加 商品的信息
     */
    @PostMapping("/insert")
    private ResponseResult<Integer> insert(@RequestBody Commodity record){
        return ResponseResult.success(commodityService.insert(record));
    }
    /*
    更新商品信息
     */
    /*@PostMapping("/updateByPrimaryKey")
    private ResponseResult<Integer> updateByPrimaryKey(@RequestBody Commodity record){
        return ResponseResult.success(commodityService.updateByPrimaryKey(record));
    }*/

    /**
     * 伪删除单个的接口
     */
    @GetMapping("/updateState")
    private ResponseResult<Integer> updateState(int id){
        return ResponseResult.success(commodityService.updateState(id));
    }
    /**
     * 编辑商品信息的接口
     */
    @PostMapping("/setNewCommodity")
    private ResponseResult<Integer>setNewCommodity(@RequestBody Commodity commodity){
        return ResponseResult.success(commodityService.setNewCommodity(commodity));
    }

    @PutMapping("/update")
    private ResponseResult<Integer> update(@RequestBody Commodity commodity) {
        return null;
    }


    /**
     * 批量删除的接口
     */
    @PostMapping("/updateStateList")
    private ResponseResult<Integer>updateStateList(List<Integer> ids){
        return ResponseResult.success(commodityService.updateStateList(ids));
    }
    /**
     * 批量伪删除接口
     */

    @PostMapping("/deleteList")
    private ResponseResult<Integer>deleteList(List<Integer> ids){
        return ResponseResult.success(commodityService.deleteList(ids));
    }




}
